<?
include("../php/conni.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="../js/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="../js/json2.js"></script>
<script type="text/javascript" src="../js/pub.js"></script>

<link href="../css/pub.css" rel="stylesheet" type="text/css" />

<link href="../css/cust.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/cust_iframe_show.js"></script>

<?

/*
if($_GET[item]==''||!$_GET[item])
{
	$query="select cust.* , cust_item.text,count(cust_visit.id) as visit_num  from cust left join cust_item on cust.type=cust_item.val left join cust_visit on cust.id=cust_visit.v_cust_id where cust_item.item='cust_type'group by cust.id ";
	
}
*/
/*
else if($_GET[item]=='query')
{
	*/
	$query="select cust.* , cust_item.text ,count(cust_visit.id) as visit_num ,sum(cust_visit.v_sum) as visit_sum from cust left join cust_item on cust.type=cust_item.val left join cust_visit on cust.id=cust_visit.v_cust_id  where cust_item.item='cust_type' ";
	if($_GET[name]!='')
	{
		$query.=" and cust.name like '%".$_GET[name]."%'";
	}
	if($_GET[company]!='')
	{
		$query.=" and cust.company like '%".$_GET[company]."%'";
	}
	if($_GET[num]!='')
	{
		$query.=" and (cust.cella like '%".$_GET[num]."%' or cust.cellb like '%".$_GET[num]."%' or cust.tel like '%".$_GET[num]."%' or cust.fax like '%".$_GET[num]."%')";
	}
	
	if($_GET[area]!='')
	{
		$query.=" and cust.area like '%".$_GET[area]."%'";
	}
	if($_GET[type]!='')
	{
		$query.=" and cust.type = '".$_GET[type]."'";
	}
	
	
//}
//$query.=" group by cust.id order by cust.id desc";
if($_GET[orde]==''||!$_GET[orde])
{
	$orde='id';
}
if($_GET[sc_orde]==''||!$_GET[sc_orde])
{
	$sc_orde='desc';
}
if($_GET[show_num]==''||!$_GET[show_num])
{
	$show_num=' LIMIT 0 , 30';
}
if($_GET[show_num]!='')
{
	$show_num=" LIMIT 0 , ".$_GET[show_num];
}

if($_GET[show_num]=='all')
{
	$show_num='';
}
//echo $_GET[show_num];

$query.=" group by cust.id order by ".$orde." ".$sc_orde.$show_num;
if($result=$conni->query($query))
{
	$i=0;
	while($row=$result->fetch_assoc())
	{
		$cust[$i]=$row;
		
		if($cust[$i][visit_sum]==''||!$cust[$i][visit_sum])
		{
			$cust[$i][visit_sum]=0;
		}
		$i++;
	}
}
?>
			
			<!--[if ie6]> 数据内容 <![endif]-->
			<div class="cust_data"  id="show_t_body">

				<?
				//echo $query;
				for($i=0;$i<count($cust);$i++)
				{
				?>
				<!--[if ie6]> 表格之间的分割线 <![endif]-->
				<div class="cust_t_text_1_line_1">
				</div>
				<div class="cust_t_text_1" name="1" id="<?=$cust[$i][id];?>">
					<!--[if ie6]> 表格之间的分割线 <![endif]-->
					<div class="cust_t_text_1_line_1">
					</div>
					<!--[if ie6]> 字段 <![endif]-->
					<div class="cust_table_top_text_2" style="width:100px;">
						<?=$cust[$i][text];?>
					</div>
					<!--[if ie6]> 表格分割线竖线 <![endif]-->
					<div class="pub_table_s_2">
					</div>
					<!--[if ie6]> 字段 <![endif]-->
					<div class="cust_table_top_text_2" style="width:150px;">
						<?=$cust[$i][name];?>
					</div>
					<!--[if ie6]> 表格分割线竖线 <![endif]-->
					<div class="pub_table_s_2">
					</div>
					<div class="cust_table_top_text_2" style="width:200px;">
						<?=$cust[$i][company];?>
					</div>
					<!--[if ie6]> 表格分割线竖线 <![endif]-->
					<div class="pub_table_s_2">
					</div>
					<div class="cust_table_top_text_2" style="width:150px;">
						<?=$cust[$i][title];?>
					</div>
					<!--[if ie6]> 表格分割线竖线 <![endif]-->
					<div class="pub_table_s_2">
					</div>
					<div class="cust_table_top_text_2" style="width:150px;">
						<?=$cust[$i][cella];?>
					</div>
					<!--[if ie6]> 表格分割线竖线 <![endif]-->
					<div class="pub_table_s_2">
					</div>
					<div class="cust_table_top_text_2" style="width:150px;">
						<?=$cust[$i][tel];?>
					</div>
					<!--[if ie6]> 表格分割线竖线 <![endif]-->
					<div class="pub_table_s_2">
					</div>
					<div class="cust_table_top_text_2" style="width:150px;">
						<?=$cust[$i][fax];?>
					</div>
					<!--[if ie6]> 表格分割线竖线 <![endif]-->
					<div class="pub_table_s_2">
					</div>
					<div class="cust_table_top_text_2" style="width:150px;">
						<?=$cust[$i][work_email];?>
					</div>
					<!--[if ie6]> 表格分割线竖线 <![endif]-->
					<div class="pub_table_s_2">
					</div>
					<div class="cust_table_top_text_2" style="width:150px;">
						<?=$cust[$i][visit_num];?>
					</div>
					<!--[if ie6]> 表格分割线竖线 <![endif]-->
					<div class="pub_table_s_2">
					</div>
					<div class="cust_table_top_text_2" style="width:150px;text-align:right">
						￥<?=sprintf("%.2f", $cust[$i][visit_sum]);?>元
					</div>
					<!--[if ie6]> 表格分割线竖线 <![endif]-->
					<div class="pub_table_s_2">
					</div>
					
				</div>
				<!--[if ie6]> 表格之间的分割线 <![endif]-->
				<div class="cust_t_text_1_line_2">
				</div>
				<?
				}
				?>

			</div>